package com.heima.stroke.handler.valuation;

public class FuelCostValuation implements Valuation {

    private Valuation valuation;

    public FuelCostValuation(Valuation valuation) {
        this.valuation = valuation;
    }

    @Override
    public float calculation(float km) {
        // 假设每公里油耗成本为固定值，例如0.5元/公里
        float fuelCostPerKm = 0.5f;
        // 计算燃油费用
        float fuelCost = km * fuelCostPerKm;
        // 如果存在装饰器，则累加其计算结果
        if (valuation != null) {
            fuelCost += valuation.calculation(km);
        }
        return fuelCost;
    }
}
